package eSchool.BL;

import eSchool.DataLayer.DAOFactory;
import eSchool.DataLayer.IDisciplinaInscritoDAO;


public class DisciplinaInscrito extends Disciplina {

    private int ano;
    private int semestre;
    private float nota;

    public DisciplinaInscrito () {
    }

    public int getAno () {
        return ano;
    }

    public void setAno (int val) {
        this.ano = val;
    }

    public float getNota () {
        return nota;
    }

    public void setNota (float val) {
        this.nota = val;
    }

    public int getSemestre () {
        return semestre;
    }

    public void setSemestre (int val) {
        this.semestre = val;
    }
    
     @Override
    public void gravaDados() throws Exception {
       // DAOFactory factory = DAOFactory.getDAOFactory(DAOFactory.ACCESS);
       // IDisciplinaDAO disciplinaDAO = factory.getDisciplinaDAO();
       // if(disciplinaDAO.findDisciplina(this.codDisciplina)== null)
       //     disciplinaDAO.insertDisciplina(this);
       // else
       //     disciplinaDAO.updateDisciplina(this);
            

    }

    @Override
    public void leDados() throws Exception {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void leDados(String codDisciplina, String numAluno) throws Exception {
        DAOFactory factory = DAOFactory.getDAOFactory(DAOFactory.ACCESS);
        IDisciplinaInscritoDAO disciplinaInscritoDAO = factory.getDisciplinaInscritoDAO();
        disciplinaInscritoDAO.findDisciplinaInscrito(this, codDisciplina, numAluno);
    }

    
    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        switch (columnIndex) {
            case 0:
                return ((Integer)ano);
            case 1:
                return ((Integer)semestre);
            case 2:
                return ((Float)nota);
            default:
                return null;
       }
    }
    
    @Override
    public int getColumnCount() {
        return 3;
    }

    @Override
    public String getColumnName(int columnIndex) {
        switch (columnIndex) {
            case 0:
                return "ano";
            case 1:
                return "semestre";
            case 2:
                return "nota";
            default:
                return null;
       }
    }

    @Override
    public Class<?> getColumnClass(int columnIndex) {
        switch (columnIndex) {
            case 0:
                return ((Integer)ano).getClass();
            case 1:
                return ((Integer)semestre).getClass();
            case 2:
                return ((Float)nota).getClass();
            default:
                return null;
       }

    }

    @Override
    public boolean isCellEditable(int rowIndex, int columnIndex) {
        return false;
    }

   
    @Override
    public void setValueAt(Object aValue, int rowIndex, int columnIndex){
        
       switch (columnIndex) {
            case 0:
                ano = ((Integer) aValue).intValue();
                break;
            case 1:
                semestre = ((Integer) aValue).intValue();
                break;
            case 2:
                nota = ((Float) aValue).floatValue();
                break;
            
        }
    }

}

